@extends('layout.main')

@section('content')
    <div class="col-sm-8 blog-main">
        <div>
            <div id="carousel-example" class="carousel slide" data-ride="carousel">
                <!-- Indicators -->
                <ol class="carousel-indicators">
                    <li data-target="#carousel-example" data-slide-to="0" class="active"></li>
                    <li data-target="#carousel-example" data-slide-to="1"></li>
                    <li data-target="#carousel-example" data-slide-to="2"></li>
                </ol><!-- Wrapper for slides -->
                <div class="carousel-inner">
                    @foreach([1, 2, 3] as $i)
                    <div class="item {{ $i == 1 ? 'active' : '' }}">
                        <img src="/image/00{{$i}}.jpg" alt="..." />
                        <div class="carousel-caption">...</div>
                    </div>
                    @endforeach
                </div>
                <!-- Controls -->
                <a class="left carousel-control" href="#carousel-example" data-slide="prev">
                    <span class="glyphicon glyphicon-chevron-left"></span></a>
                <a class="right carousel-control" href="#carousel-example" data-slide="next">
                        <span class="glyphicon glyphicon-chevron-right"></span></a>
            </div>
        </div>
        <div style="height: 20px;"></div>
        <div>
            @foreach($posts as $post)
            <div class="blog-post">
                <h2 class="blog-post-title"><p onclick="location.href=this.dataset.url" data-url="/posts/{{ $post->id }}" >{{ $post->title }}</p></h2>
                <p class="blog-post-meta"> {{ $post->created_at->format('Y年m月d日') }} &nbsp;&nbsp;&nbsp; 作者: <a href="/user/{{ $post->user->id }}"> {{ $post->user->name }} </a></p>
                <div> {!! str_limit(strip_tags($post->content), 200, '...') !!} </div>
                <p class="blog-post-meta">赞 {{ $post->zans_count }}  | 评论 {{ $post->comments_count }}</p>
            </div>
            @endforeach

            {{ $posts->links() }}
        </div>
    </div>
@endsection